import { queryCompanyList, queryExhibitionParamlist } from '@/services/institution';
import { useState, useEffect } from 'react';
export const useData = () => {
  const [fairSelectData, setFairSelectData] = useState<any[]>([]);
  const [unitSelectData, setUnitSelectData] = useState<any[]>([]);

  useEffect(() => {
    // 参展展览筛选列表
    queryExhibitionParamlist().then(res => {
      if (res?.responseCode == 200) {
        setFairSelectData(res?.data?.pagedItems ?? []);
      }
    });

    // 单位请求筛选列表
    queryCompanyList().then(res => {
      if (res?.responseCode == 200) {
        setUnitSelectData(res?.data ?? []);
      }
    });

    return () => {
      setFairSelectData([]);
      setUnitSelectData([]);
    };
  }, []);

  // 列表状态的数据
  let statusData: any = [
    {
      exhibitionName: '未上传印稿',
      id: 0,
    },
    {
      exhibitionName: '已上传印稿',
      id: 1,
    },
    {
      exhibitionName: '印稿已审阅',
      id: 2,
    },
    {
      exhibitionName: '已上传此稿',
      id: 9999,
    },
    {
      exhibitionName: '已完成终稿',
      id: 3,
    },
    {
      exhibitionName: '已收到实体印章',
      id: 4,
    },
  ];

  let writerArr: any = [];

  return { fairSelectData, unitSelectData, statusData, writerArr };
};
